#include <iostream>

using namespace std;

typedef long long LL;

const int N = 1e6 + 10;
int n, m, maxlen;
int a[N];

LL calc(int x)
{
	LL ret = 0;
	for(int i = 1; i <= n; i++) 
	if(a[i] > x)
	ret += a[i] - x;
	return ret;
}

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		maxlen = max(maxlen, a[i]);
	} 
	int l = 0, r = maxlen;
	while(l < r)
	{
		int mid = (l + r + 1) >> 1;
		LL h = calc(mid);
		if(h >= m) l = mid;
		else r = mid - 1;
	}
	cout << l << endl;
	
	return 0;
}
